<?php
/* @var $this yii\web\View */

use common\helpers\Html;
use yii\helpers\Url;
use common\assets\WeuiPluginAsset;

$this->title = '视频学院';

WeuiPluginAsset::register($this);
$this->registerJs($this->render('_script.js'));
?>
<?= Html::tag('div', '', $headerOptions) ?>

<?php if (!empty($menus)): ?>
    <div class="dashboard">
        <div class="weui-flex weui-flex-noborder">
            <?php foreach ($menus as $menu): ?>
                <div class="weui-flex__item">
                    <a href="<?= Url::to(['list', 'id' => $menu->id]) ?>">
                        <?= Html::img($menu->thumb, ['class' => 'weui-grid__icon'], true) ?>
                        <p><?= $menu->name ?></p>
                    </a>
                </div>
            <?php endforeach; ?>
        </div>
    </div>
<?php endif; ?>

<?php if (!empty($dataProvider->totalCount)): ?>
    <?php foreach ($dataProvider->models as $data): ?>
        <div class="weui-cells no-border">
            <a class="weui-cell weui-cell_access" href="<?= Url::to(['list', 'id' => $data->id]) ?>">
                <div class="weui-cell__bd">
                    <h3 class="vertical-line-tag"><?= $data->name ?><small>共<?= $videos = count($data->videosRecommend) ?>个视频</small></h3>
                </div>
                <div class="weui-cell__ft"></div>
            </a>
            <div class="scoller-horizontal">
                <div class="scoller-wrap">
                    <ul class="horizontal-panel-box">
                        <?php if ($videos): ?>
                            <?php foreach ($data->videosRecommend as $video): ?>
                                <li>
                                    <a href="<?= Url::to(['view', 'id' => $video->id]) ?>" class="panel-item">
                                        <div class="panel-media">
                                            <?= Html::img($video->cover, '', true) ?>
                                        </div>
                                        <div class="panel-body">
                                            <h2><?= $video->title ?></h2>
                                            <p><?= $video->description ?></p>
                                        </div>
                                    </a>
                                </li>
                            <?php endforeach; ?>
                            <li>
                                <a href="<?= Url::to(['list', 'id' => $data->id]) ?>" class="panel-item">
                                    <div class="panel-media">
                                        更多
                                    </div>
                                </a>
                            </li>
                        <?php else: ?>
                            <li>
                                <a href="javascript:;" class="panel-item">
                                    <div class="panel-media">
                                        暂无视频
                                    </div>
                                </a>
                            </li> 
                        <?php endif; ?>
                    </ul>
                </div>
            </div>
        </div>
    <?php endforeach; ?>
<?php endif; ?>
